<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    let vm = {
        template: `
                    <div @click="handler">{{msg}}</div>
                    <div>
                        {{obj.name}}
                        {{obj.age}}
                    </div>
                    <div v-for="item in arr">
                        {{item}}
                    </div>
                `,
        setup () {
            const { ref, reactive } = Vue
            // 定义变量
            let msg = ref('hello')
            let arr = reactive(['a', 'b', 'c'])
            let obj = reactive({ name: 'GalaxySa' })
            // 定义函数
            const handler = () => {
                console.log('click');
                // ref数据的调用方式
                msg.value = "haha"
                obj.name = "SliverTrain"
                arr.push('d')
                obj.age = 12
            }

            return { msg, arr, obj, handler }
        }
    }
    let app = Vue.createApp(vm)
    app.mount('#app')
</script>

</html>